#ifndef _PUBLIC_H_
#define _PUBLIC_H_


#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include "nvs_flash.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_timer.h"
#include "esp_log.h"
#include "wifi_config.h"
#include "driver/uart.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/sockets.h"
#include "lwip/inet.h"
#include "driver/gpio.h"
#include "bsp_led.h"
#include "cJSON.h"
#include "usart.h"
#include "driver/uart.h"     
#include "freertos/queue.h"  
#include "bsp_http.h"


#define CURRENT_VERSION 20250328

typedef enum {
    CAR_NOT_CONNETCT = 0,   // 卡片未连接
    CAR_READ_SUCCESS,       // 读卡成功
    CAR_LEAVE,              // 卡片 离开
    CAR_READ_PIECED,        // 读取卡片块数据 65块 数据
    CAR_WAIT_OPERATE,       // 等待卡片操作状态
    CAR_WRITE_BLAKE_DATA,   //卡片写块状态
    CAR_WRITE_BLAKE_SUCCESS,            // 写操作成功
    CAR_WRITE_BLAKE_FAIL,                // 写操作失败
    CAR_READ_BLAKE_DATA,     //卡片读块数据
    CAR_READ_BLAKE_SUCCESS,            // 读操作成功
    CAR_READ_BLAKE_FAIL                // 读操作失败
    
    // ERR_LENGTH_MISMATCH,
    // ERR_CHECKSUM
} RfidResult;

typedef struct
{
    bool bolck_flag;
    RfidResult car_state;
    uint8_t bolck_addr;
    uint8_t rfid_drive_flag; // rfid设备是否存在
    uint8_t bolck_data[16];   // 65块数据存储
    uint8_t write_data[16];   // 写块数据
    uint8_t write_cnt;
    uint8_t read_date[16];     // 读到块地址
    uint8_t read_cnt;
    uint8_t card_id_str[16];  // 卡号
}RFID_DEVICE;

extern RFID_DEVICE gs_rfid;


// extern uint8_t bolck_data[16];
// extern bool bolck_flag;
// extern uint8_t rfid_drive_flag; // rfid设备是否存在

extern char ssid[32];
extern char password[64];

extern char SoftWifiName[32];
extern char SoftWifiPass[64];



#endif







